//
//  YHYMainBusinessViewController.m
//  Home
//
//  Created by 杨泓晔 on 16/6/22.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "YHYMainBusinessViewController.h"
#import "ChongViewController.h"
#import "LingViewController.h"
#import "LewPopupViewAnimationSpring.h"
#import "WSMineCell.h"
#import "WSMineHeadSubView.h"
#import "TLAdvertisementTableViewCell.h"
#import "YHYShowActivityViewController.h"//发布活动
#import "WSMineFooterView.h"
#import "TLPublishViewController.h"
#import "YHYExpandViewController.h"
#import "YHYShareView.h"
@interface YHYMainBusinessViewController()<UITableViewDataSource,UITableViewDelegate,WSMineFooterViewDelegate>
{
    
    
    UIView *headerView;
    UILabel *yuanlabel;
    UIButton *problemButton;
    UILabel *lineLabel;
    UILabel *textL;
    
}
@property (nonatomic,retain) UIView *myheaderView;
@property (nonatomic, strong) UITableView *myTableView;
@property (nonatomic,strong) NSArray *titleArr;
@property (nonatomic, strong) WSMineHeadSubView *subCVView;
@property (nonatomic, strong) WSMineHeadSubView *subTalkView;
@property (nonatomic, strong) WSMineHeadSubView *subCollectView;


@property (nonatomic,retain)UIView *alertView;


@end

@implementation YHYMainBusinessViewController

-(void) viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBarHidden=YES;
    self.tabBarController.tabBar.hidden=NO;
    
}

-(void) viewWillDisappear:(BOOL)animated
{
    self.navigationController.navigationBarHidden=NO;
    self.tabBarController.tabBar.hidden=NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor=LV;
    _titleArr=[NSArray arrayWithObjects:@"我的主页",@"我的钱包", nil];
    
    [self createHeader];
}

#pragma mark 顶部

-(void) createHeader{
    //    //背景图
    _myheaderView=[[UIView alloc]init];
    _myheaderView.backgroundColor=GH;
    [self.view addSubview:_myheaderView];
    [_myheaderView mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.top.equalTo(self.view).offset(0);
        make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width, 64*AUTO_HEIGHT));
    }];
    
//    //按钮
//    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
//    [btn setImage:[UIImage imageNamed:@"fahui"] forState:UIControlStateNormal];
//    [btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
//    [_myheaderView addSubview:btn];
//    [btn mas_makeConstraints:^(MASConstraintMaker *make){
//        
//        make.top.equalTo(_myheaderView).offset(51/2 *AUTO_HEIGHT);
//        make.left.equalTo(self.view).offset(20/2 *AUTO_WIDTH);
//        make.size.mas_equalTo(CGSizeMake(34 *AUTO_WIDTH, 34 *AUTO_HEIGHT));
//        
//    }];
    //零钱
    UILabel *linglabel=[[UILabel alloc]init];
    linglabel.text=@"零钱";
    linglabel.textColor=[UIColor whiteColor];
    linglabel.adjustsFontSizeToFitWidth=YES;
    linglabel.textAlignment=NSTextAlignmentCenter;
    linglabel.font=[UIFont systemFontOfSize:ONETEXTWIDTH];
    [_myheaderView addSubview:linglabel];
    [linglabel mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.top.equalTo(_myheaderView).offset(66/2 *AUTO_HEIGHT);
        make.left.equalTo(_myheaderView).offset((self.view.frame.size.width-100 *AUTO_WIDTH)/2);
        make.size.mas_equalTo(CGSizeMake(100*AUTO_WIDTH, 20 *AUTO_HEIGHT));
        
    }];
    
    
    //零钱明细
    UILabel *qianlabel=[[UILabel alloc]init];
    qianlabel.text=@"零钱明细";
    qianlabel.textColor=[UIColor whiteColor];
    qianlabel.font=[UIFont systemFontOfSize:16];
    qianlabel.textAlignment=NSTextAlignmentRight;
    qianlabel.userInteractionEnabled=YES;
    UITapGestureRecognizer *qiantap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(qantap:)];
    [qianlabel addGestureRecognizer:qiantap];
    [_myheaderView addSubview:qianlabel];
    [qianlabel mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.top.equalTo(_myheaderView.mas_top).offset(66/2 *AUTO_HEIGHT);
        make.right.equalTo(self.view).offset(-30/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(80 *AUTO_WIDTH,20 *AUTO_HEIGHT));
    }];
    
    _myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 60.00*AUTO_HEIGHT, KScreenWidth, SCREEN_HEIGHT - 60 * AUTO_HEIGHT ) style:UITableViewStyleGrouped];
//    [self.view addSubview:_myTableView];
    [self.view addSubview:_myTableView];
    _myTableView.dataSource = self;
    _myTableView.delegate = self;
    _myTableView.backgroundColor = LV;
    headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenHeight, 180.00*AUTO_HEIGHT)];
    headerView.backgroundColor = GH;
    
    _myTableView.tableHeaderView = headerView;
    [_myTableView registerClass:[WSMineCell class] forCellReuseIdentifier:@"WSMineCell"];
     self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [_myTableView registerClass:[TLAdvertisementTableViewCell class] forCellReuseIdentifier:@"adCell"];
    self.myTableView.sectionFooterHeight = 10;

    
    [self addButton];
//    [self addProblem];
    
    
}


//常见问题
//-(void)addProblem{
//    
//    problemButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    [_myTableView addSubview:problemButton];
//    [problemButton setTitle:@"常见问题" forState:UIControlStateNormal];
//    problemButton.titleLabel.font=[UIFont systemFontOfSize:14.00*AUTO_HEIGHT];
//    problemButton.alpha = 0.7;
//    [problemButton setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
//    [problemButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        
//        make.bottom.equalTo(_myTableView).offset(KScreenHeight - 80);
//        make.size.mas_equalTo(CGSizeMake(KScreenWidth, 20));
//        
//    }];
//    
//}
//
-(void)addButton{
    
    //图片
    UIImageView *image=[[UIImageView alloc]init];
    image.image=[UIImage imageNamed:@"find_RMB"];
    [headerView addSubview:image];
    [image mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(headerView.mas_top).offset(36 *AUTO_HEIGHT);
        make.left.equalTo(self.view).offset(230/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(18 *AUTO_WIDTH, 18*AUTO_HEIGHT));
    }];
    
    //0.10
    yuanlabel=[[UILabel alloc]init];
    yuanlabel.text=@"0.10";
    yuanlabel.textColor=[UIColor whiteColor];
    yuanlabel.font=[UIFont fontWithName:SHUZI size:45];
    yuanlabel.textAlignment=NSTextAlignmentCenter;
    [headerView addSubview:yuanlabel];
    [yuanlabel mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.top.equalTo(headerView.mas_top).offset(30 *AUTO_HEIGHT);
        make.left.equalTo(image).offset(10 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(100 *AUTO_WIDTH, 35 *AUTO_HEIGHT));
    }];
    
    
    //余额
    UILabel *yulabel=[[UILabel alloc]init];
    yulabel.text=@"余额（元）";
    yulabel.textColor=[UIColor whiteColor];
    yulabel.font=[UIFont systemFontOfSize:15];
    [headerView addSubview:yulabel];
    [yulabel mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.top.equalTo(yuanlabel.mas_bottom).offset(10/2 *AUTO_HEIGHT);
        make.left.equalTo(self.view).offset(285/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(90 *AUTO_WIDTH, 20 *AUTO_HEIGHT));
    }];
    
    //横线
    UILabel *henglabel=[[UILabel alloc]init];
    henglabel.backgroundColor=[UIColor grayColor];
    henglabel.alpha=0.2;
    henglabel.layer.shadowOffset=CGSizeMake(0.8f, 1.0f);
    henglabel.layer.shadowOpacity=1.0f;
    [headerView addSubview:henglabel];
    [henglabel mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.bottom.equalTo(headerView.mas_bottom).offset(-34 *AUTO_HEIGHT);
        make.left.equalTo(self.view).offset(0);
        make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width, 1*AUTO_HEIGHT));
    }];
    
    //竖线
    UILabel *shulabel=[[UILabel alloc]init];
    shulabel.backgroundColor=[UIColor whiteColor];
    shulabel.alpha=0.6;
    [headerView addSubview:shulabel];
    [shulabel mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.top.equalTo(henglabel.mas_bottom).offset(10/2 *AUTO_HEIGHT);
        make.left.equalTo(self.view).offset(self.view.frame.size.width/2);
        make.size.mas_equalTo(CGSizeMake(1 *AUTO_WIDTH, 25 *AUTO_HEIGHT));
    }];
    
    
    //充值按钮
    UIButton *chongbtn=[UIButton buttonWithType: UIButtonTypeCustom];
    chongbtn.tag = 1000;
    [chongbtn setTitle:@"充值" forState:UIControlStateNormal];
    [chongbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    chongbtn.titleLabel.font=[UIFont systemFontOfSize:16];
    [chongbtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [headerView addSubview:chongbtn];
    [chongbtn mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.top.equalTo(henglabel.mas_bottom).offset(0);
        make.left.equalTo(self.view).offset(0);
        make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width/2, 64/2 *AUTO_HEIGHT));
    }];
    
    
    //充值图片
    UIImageView *chongimage=[[UIImageView alloc]init];
    chongimage.image=[UIImage imageNamed:@"yuan"];
    [headerView addSubview:chongimage];
    [chongimage mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.top.equalTo(chongbtn.mas_top).offset(10/2 *AUTO_HEIGHT);
        make.left.equalTo(self.view).offset(95/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(22 *AUTO_WIDTH, 22 *AUTO_HEIGHT));
    }];
    
    
    //提现按钮
    UIButton *tibtn=[UIButton buttonWithType:UIButtonTypeCustom];
    tibtn.tag = 2000;
    [tibtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [tibtn setTitle:@"提现" forState:UIControlStateNormal];
    [tibtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    tibtn.titleLabel.font=[UIFont systemFontOfSize:16];
    [headerView addSubview:tibtn];
    [tibtn mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.top.equalTo(henglabel.mas_bottom).offset(0);
        make.right.equalTo(self.view).offset(0);
        make.size.mas_equalTo(CGSizeMake(self.view.frame.size.width/2, 64/2 *AUTO_HEIGHT));
        
    }];
    
    
    //提现图片
    UIImageView *timage=[[UIImageView alloc]init];
    timage.image=[UIImage imageNamed:@"yuan1"];
    [headerView addSubview:timage];
    [timage mas_makeConstraints:^(MASConstraintMaker *make){
        
        make.top.equalTo(tibtn.mas_top).offset(10/2 *AUTO_HEIGHT);
        make.left.equalTo(shulabel).offset(95/2 *AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(22 *AUTO_WIDTH, 22 *AUTO_HEIGHT));
    }];
    
    
    
    
    
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

       return 1;

    
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 4;
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellWithIdentifier = @"WSMineCell";
    WSMineCell *cell = [tableView dequeueReusableCellWithIdentifier:CellWithIdentifier];
    cell.backgroundColor = [UIColor whiteColor];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (indexPath.section == 0) {
      //  WSMineHeadSubView *footView = [[WSMineHeadSubView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 200 * AUTO_WIDTH)];
        for (int i = 0; i < 3; i++) {
            WSMineHeadSubView *threeView = [[WSMineHeadSubView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH /3 * i ,  0, SCREEN_WIDTH / 3, 75 * AUTO_HEIGHT)];
            threeView.type = i + 1;
            if (threeView.type == 1) {
                threeView.icoImage.image = [UIImage imageNamed:@"minerelease"];
                threeView.typeLabel.text = @"发布过";
            }
            threeView.numberStr = @"123";
            threeView.backgroundColor = [UIColor whiteColor];
            [cell addSubview:threeView];
        }
        
        
    }
    if (indexPath.section == 1 || indexPath.section == 2 ) {
        
        
        if (indexPath.section == 1) {
            cell.titleLabel.text = @"公司主页";
            cell.icoImage.image = [UIImage imageNamed:@"buMainL"];
        }
//        if (indexPath.section == 2) {
//            cell.titleLabel.text = @"主页推广";
////            cell.icoImage.image = [UIImage imageNamed];
//        }
//       
        if (indexPath.section == 2) {
    
            cell.titleLabel.text = @"发布活动";
            cell.icoImage.image = [UIImage imageNamed:@"main_cell@2p"];
        }
       
        
        
    }
    if (indexPath.section == 3) {
        WSMineFooterView *footView = [[WSMineFooterView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 300 * AUTO_WIDTH)];
        footView.delegate = self;
        footView.singImage.image = [UIImage imageNamed:@"buMainSecond"];
       footView.qiandaoLabel.text = @"主页推广";
        footView.pairImage.image = [UIImage imageNamed:@"buMainFirst"];
        footView.vipImage.image = [UIImage imageNamed:@"buMainthird"];
        footView.renzhnegLabel.text = @"其他";
        footView.supeiLabel.text = @"活动推广";
        [cell addSubview:footView];
    }

    return cell;

}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    

    if (indexPath.section == 2) {
        YHYShowActivityViewController *activity = [YHYShowActivityViewController new];
        [self.navigationController pushViewController:activity animated:YES];
    }
    if (indexPath.section == 1) {
        YHYExpandViewController *expend = [YHYExpandViewController new];
        [self.navigationController pushViewController:expend animated:YES];

        }
  
    
}
- (void)animateView{
    
    
   // self.isON= !self.isON;
    self.alertView = [[UIView alloc]init];
    //self.alertView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.alertView];
    
    self.alertView.alpha = 0;
    [UIView animateWithDuration:0.08 animations:^{
        
        //        self.aView.frame = CGRectMake(40, 90, 120, 60);
      //  self.alertView.center = CGPointMake(self.view.frame.size.width/2 , 0 );
        self.alertView.frame = CGRectMake(50.00*AUTO_WIDTH,490/3 * AUTO_HEIGHT, self.view.frame.size.width - 100.00*AUTO_WIDTH, 600/2.00*AUTO_WIDTH);
        //
    } completion:^(BOOL finished) {
        
        [UIView animateWithDuration:0.005 animations:^{
           // self.alertView.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2 );
             self.alertView.frame = CGRectMake(50.00*AUTO_WIDTH,490/3 * AUTO_HEIGHT, self.view.frame.size.width - 100.00*AUTO_WIDTH, 600/2.00*AUTO_WIDTH);
            
            
            
        }];
        
        
    }];
    
    self.alertView.layer.masksToBounds = YES;
    self.alertView.layer.cornerRadius = 15.00*AUTO_WIDTH;
    self.alertView.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
    self.alertView.alpha = 0;
    
    
    
    UIImageView *lvHead = [UIImageView new];
    [self.alertView addSubview:lvHead];
    [lvHead mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.alertView);
        make.left.width.mas_equalTo(self.alertView);
        make.height.mas_equalTo(self.alertView);
        
    }];
    lvHead.image = [UIImage imageNamed:@"greenbackView"];
    
    
    UIImageView *head = [UIImageView new];
    [lvHead addSubview:head];
    [head mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20 * AUTO_HEIGHT);
        make.centerXWithinMargins.mas_equalTo(lvHead);
       // make.left.mas_equalTo(120 * AUTO_WIDTH);
        make.width.mas_equalTo(80 * AUTO_WIDTH);
        make.height.mas_equalTo(80 * AUTO_HEIGHT);
        
    }];
    head.image = [UIImage imageNamed:@"businessHead"];
    
    
    UILabel *sangjia = [UILabel new];
    [lvHead addSubview:sangjia];
    [sangjia mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(head.mas_bottom).offset(3 * AUTO_HEIGHT);
        make.centerXWithinMargins.mas_equalTo(lvHead);
        make.height.mas_equalTo(15 * AUTO_HEIGHT);
        
    }];
    sangjia.text = @"商家推广（聊天付费）";
    sangjia.textColor = [UIColor whiteColor];
    sangjia.font = [UIFont fontWithName:@"Arial" size:TEXTCONTENTFONT2];
    
    
    
    UILabel *textl = [UILabel new];
    [lvHead addSubview:textl];
    [textl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(440 /3 * AUTO_HEIGHT);
        make.left.mas_equalTo(lvHead.mas_left).offset(60/3 * AUTO_WIDTH);
        make.right.mas_equalTo(- 60/3 * AUTO_WIDTH);
        
    }];
    textl.numberOfLines = 2;
    textl.text = @"商家将主页发布到推荐列表展示，并以按沟通人数收取费用";
    textl.textColor = ZI;
    textl.textAlignment = NSTextAlignmentCenter;
    textl.font = [UIFont fontWithName:@"Arial" size:TEXTCONTENTFONT2];
   // NSString *labelText = @"可以自己按照宽高，字体大小，来计算有多少行。。然后。。。每行画一个UILabel。。高度自己可以控制把这个写一个自定义的类。 ";
    
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:textl.text];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    
    [paragraphStyle setLineSpacing:2* AUTO_HEIGHT];//调整行间距
    
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [textl.text length])];
    textl.attributedText = attributedString;
    textl.textAlignment = NSTextAlignmentCenter;

//    [textl sizeToFit];
    
    
    
    
    
    
    
    UIImageView *price = [UIImageView new];
    [lvHead addSubview:price];
    [price mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(textl.mas_bottom).offset(16/2 * AUTO_HEIGHT);
        make.left.mas_equalTo(280/3 * AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(15 * AUTO_WIDTH, 15 * AUTO_HEIGHT));
        
    }];
    price.image = [UIImage imageNamed:@"businessPrice"];
    
    
    
    
    UILabel *priceL = [UILabel new];
    [lvHead addSubview:priceL];
    [priceL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(price);
        make.left.mas_equalTo(price.mas_right).offset(14 * AUTO_WIDTH);
        make.height.mas_equalTo(price);
        
    }];
    priceL.text = @"12元／次";
    priceL.textColor = ZI;
    priceL.textAlignment = NSTextAlignmentCenter;
    priceL.font = [UIFont fontWithName:@"Arial" size:TEXTLABELFONT];
    

    
    
    UIButton *share = [UIButton buttonWithType:UIButtonTypeCustom];
    // [quxiaoButton setImage:[UIImage imageNamed:@"picker_can"] forState:UIControlStateNormal];
    [share addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
    lvHead.userInteractionEnabled = YES;
    [lvHead addSubview:share];
    
    //self.saveButton = [UIButton buttonWithType:UIButtonTypeCustom];
   share.backgroundColor = GH;
   share.layer.masksToBounds = YES;
    share.layer.cornerRadius = 3;
    
    [share setTitle:@"主页发布" forState:UIControlStateNormal];
    [share addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
    [share setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    // [self.button setTitleColor:HS forState:UIControlStateNormal];
    //    self.button.frame = CGRectMake(50.00*AUTO_WIDTH, 600.00*AUTO_WIDTH, 275.00*AUTO_WIDTH, 40.00*AUTO_WIDTH);
    share.titleLabel.font = [UIFont fontWithName:@"Arial" size:TEXTCONTENTFONT * TEXTWEIGHT];
    
    

    [share mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.alertView.mas_bottom).offset(-60.00*AUTO_WIDTH);
        make.right.equalTo(self.alertView.mas_right).offset(-80.00*AUTO_WIDTH);
        make.left.equalTo(self.alertView).offset(80.00*AUTO_WIDTH);
        //  make.size.mas_equalTo(CGSizeMake(20.00*WEIGHT,30.00*WEIGHT));
        make.height.mas_equalTo(30 * AUTO_HEIGHT);

        
    }];

    
    
    
    
    
    UIButton *chungajianButton = [UIButton buttonWithType:UIButtonTypeCustom];
   // [chungajianButton addTarget:self action:@selector(chuangjianActon:) forControlEvents:UIControlEventTouchUpInside];
    chungajianButton.layer.masksToBounds = YES;
    chungajianButton.layer.cornerRadius = 3;
    [chungajianButton setTitle:@"取消" forState:UIControlStateNormal];
    chungajianButton.backgroundColor  = GH;
    chungajianButton.titleLabel.font = [UIFont fontWithName:@"Arial" size:TEXTCONTENTFONT * TEXTWEIGHT];
    [chungajianButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [self.alertView addSubview:chungajianButton];
    [chungajianButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.alertView.mas_bottom).offset(-20.00*AUTO_WIDTH);
        make.right.equalTo(self.alertView.mas_right).offset(-80.00*AUTO_WIDTH);
        make.left.equalTo(self.alertView).offset(80.00*AUTO_WIDTH);
        //  make.size.mas_equalTo(CGSizeMake(20.00*WEIGHT,30.00*WEIGHT));
        make.height.mas_equalTo(30 * AUTO_HEIGHT);
        
    }];
    
    
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(TapAction:)];
    self.alertView.userInteractionEnabled = YES;
    [self.alertView addGestureRecognizer:tap];

    
}

- (void)shareAction:(UIButton *)btu{
    NSLog(@"eeee");
    YHYShareView *viewS = [[YHYShareView alloc]initWithFrame:CGRectMake(70 * AUTO_WIDTH, 70 * AUTO_HEIGHT, SCREEN_WIDTH - 80 * AUTO_WIDTH, SCREEN_HEIGHT - 210 * AUTO_HEIGHT)];
    [self.view addSubview:viewS];
    viewS.userInteractionEnabled = YES;
      [self lew_presentPopupView:viewS animation:[LewPopupViewAnimationSpring new] dismissed:^{
       
        
    }];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(TapActionTwo:)];
  
    [viewS addGestureRecognizer:tap];

}

- (void)TapAction:(UITapGestureRecognizer *)tap{
    
    NSLog(@"dqwd");
    [self lew_dismissPopupView];
}


-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 0.1;
}

//
//-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
//    
//    if (indexPath.section == 2 || indexPath.section == 3) {
//        return  200 *AUTO_WIDTH;
//    }
//    else {
//        
//        return 44 *AUTO_WIDTH;
//    }
//}
//


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 75 * AUTO_HEIGHT;
        
    }
    if (indexPath.section == 1 || indexPath.section == 2) {
        return 44 * AUTO_HEIGHT;
    }
    if (indexPath.section == 3) {
        return 300;
    }
    else{
        return 44 * AUTO_HEIGHT;
    }
}



//充值
-(void) btnClick:(UIButton *) btn
{
    if (btn.tag == 1000) {
        ChongViewController *chong=[[ChongViewController alloc]init];
        [self.navigationController pushViewController:chong animated:YES];
    }
    
    else if(btn.tag == 2000) {
        if (yuanlabel.text.intValue <= 99) {
            
            textL = [UILabel new];
            [self.myTableView addSubview:textL];
            textL.text = @"      余额不足100元，    无法提现   ";
            textL.textColor = [UIColor whiteColor];
            textL.backgroundColor = GH;
            textL.numberOfLines = 2;
            textL.layer.cornerRadius = 20 * AUTO_WIDTH;
            textL.layer.masksToBounds = YES;
            textL.font = [UIFont fontWithName:nil size:13 * AUTO_WIDTH];
            textL.textAlignment = NSTextAlignmentCenter;
            [textL mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.mas_equalTo(_myTableView.mas_top).offset(250 * AUTO_HEIGHT);
                make.width.mas_equalTo(140 * AUTO_WIDTH);
                make.height.mas_equalTo(40 * AUTO_HEIGHT);
                make.centerXWithinMargins.mas_equalTo(self.myTableView);
                
            }];

//            [UIView animateWithDuration:2.f animations:^{
//                
//                textL.alpha = 0;
//            } completion:^(BOOL finished) {
//             //   [textL removeFromSuperview];
//                
//            }];
            [UIView animateWithDuration:2.f animations:^{
                textL.alpha = 0;
                
            }];
        }
        
        
    }
}
//
//零钱明细
-(void) qantap:(UITapGestureRecognizer *) tap
{
    LingViewController *ling=[[LingViewController alloc]init];
    [self.navigationController pushViewController:ling animated:YES];
}

#pragma mark - 协议
//footView Of three
- (void)footerPushViewController:(NSInteger)type{
    if (type == 1200) {
        [self animateView];
        self.view.backgroundColor = [UIColor whiteColor];
        [self lew_presentPopupView:_alertView animation:[LewPopupViewAnimationSpring new] dismissed:^{
            NSLog(@"hhhhhh");
            
            
        }];

    }
    if (type == 1201) {
        [self animationTwo];
        [self lew_presentPopupView:self.alertView animation:[LewPopupViewAnimationSpring new] dismissed:^{
        }];
    }
    
}


- (void)animationTwo{
    // self.isON= !self.isON;
    self.alertView = [[UIView alloc]init];
    //self.alertView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.alertView];
    
    self.alertView.alpha = 0;
    [UIView animateWithDuration:0.08 animations:^{
        
        //        self.aView.frame = CGRectMake(40, 90, 120, 60);
        //  self.alertView.center = CGPointMake(self.view.frame.size.width/2 , 0 );
        self.alertView.frame = CGRectMake(50.00*AUTO_WIDTH,490/3 * AUTO_HEIGHT, self.view.frame.size.width - 100.00*AUTO_WIDTH, 600/2.00*AUTO_WIDTH);
        //
    } completion:^(BOOL finished) {
        
        [UIView animateWithDuration:0.005 animations:^{
            // self.alertView.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2 );
            self.alertView.frame = CGRectMake(50.00*AUTO_WIDTH,490/3 * AUTO_HEIGHT, self.view.frame.size.width - 100.00*AUTO_WIDTH, 600/2.00*AUTO_WIDTH);
            
            
            
        }];
        
        
    }];
    
    self.alertView.layer.masksToBounds = YES;
    self.alertView.layer.cornerRadius = 15.00*AUTO_WIDTH;
    self.alertView.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
    self.alertView.alpha = 0;
    
    
    
    UIImageView *lvHead = [UIImageView new];
    [self.alertView addSubview:lvHead];
    [lvHead mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.alertView);
        make.left.width.mas_equalTo(self.alertView);
        make.height.mas_equalTo(self.alertView);
        
    }];
    lvHead.image = [UIImage imageNamed:@"greenbackView"];
    
    
    UIImageView *head = [UIImageView new];
    [lvHead addSubview:head];
    [head mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(20 * AUTO_HEIGHT);
        make.centerXWithinMargins.mas_equalTo(lvHead);
        // make.left.mas_equalTo(120 * AUTO_WIDTH);
        make.width.mas_equalTo(80 * AUTO_WIDTH);
        make.height.mas_equalTo(80 * AUTO_HEIGHT);
        
    }];
    head.image = [UIImage imageNamed:@"businessHead"];
    
    
    UILabel *sangjia = [UILabel new];
    [lvHead addSubview:sangjia];
    [sangjia mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(head.mas_bottom).offset(3 * AUTO_HEIGHT);
        make.centerXWithinMargins.mas_equalTo(lvHead);
        make.height.mas_equalTo(15 * AUTO_HEIGHT);
        
    }];
    sangjia.text = @"活动推广（聊天付费）";
    sangjia.textColor = [UIColor whiteColor];
    sangjia.font = [UIFont fontWithName:@"Arial" size:TEXTCONTENTFONT2];
    
    
    
    UILabel *textl = [UILabel new];
    [lvHead addSubview:textl];
    [textl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(440 /3 * AUTO_HEIGHT);
        make.left.mas_equalTo(lvHead.mas_left).offset(60/3 * AUTO_WIDTH);
        make.right.mas_equalTo(- 60/3 * AUTO_WIDTH);
        
    }];
    textl.numberOfLines = 2;
    textl.text = @"商家将活动发布到推荐列表展示，并以按沟通人数收取费用";
    textl.textColor = ZI;
    textl.textAlignment = NSTextAlignmentCenter;
    textl.font = [UIFont fontWithName:@"Arial" size:TEXTCONTENTFONT2];
    // NSString *labelText = @"可以自己按照宽高，字体大小，来计算有多少行。。然后。。。每行画一个UILabel。。高度自己可以控制把这个写一个自定义的类。 ";
    
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:textl.text];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    
    [paragraphStyle setLineSpacing:2* AUTO_HEIGHT];//调整行间距
    
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [textl.text length])];
    textl.attributedText = attributedString;
    textl.textAlignment = NSTextAlignmentCenter;
    
    //    [textl sizeToFit];
    
    
    
    
    
    
    
    UIImageView *price = [UIImageView new];
    [lvHead addSubview:price];
    [price mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(textl.mas_bottom).offset(16/2 * AUTO_HEIGHT);
        make.left.mas_equalTo(280/3 * AUTO_WIDTH);
        make.size.mas_equalTo(CGSizeMake(15 * AUTO_WIDTH, 15 * AUTO_HEIGHT));
        
    }];
    price.image = [UIImage imageNamed:@"businessPrice"];
    
    
    
    
    UILabel *priceL = [UILabel new];
    [lvHead addSubview:priceL];
    [priceL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(price);
        make.left.mas_equalTo(price.mas_right).offset(14 * AUTO_WIDTH);
        make.height.mas_equalTo(price);
        
    }];
    priceL.text = @"12元／次";
    priceL.textColor = ZI;
    priceL.textAlignment = NSTextAlignmentCenter;
    priceL.font = [UIFont fontWithName:@"Arial" size:TEXTLABELFONT];
    
    
    
    
    UIButton *share = [UIButton buttonWithType:UIButtonTypeCustom];
    // [quxiaoButton setImage:[UIImage imageNamed:@"picker_can"] forState:UIControlStateNormal];
    [share addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
    lvHead.userInteractionEnabled = YES;
    [lvHead addSubview:share];
    
    //self.saveButton = [UIButton buttonWithType:UIButtonTypeCustom];
    share.backgroundColor = GH;
    share.layer.masksToBounds = YES;
    share.layer.cornerRadius = 3;
    
    [share setTitle:@"预览" forState:UIControlStateNormal];
    [share addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
    [share setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    // [self.button setTitleColor:HS forState:UIControlStateNormal];
    //    self.button.frame = CGRectMake(50.00*AUTO_WIDTH, 600.00*AUTO_WIDTH, 275.00*AUTO_WIDTH, 40.00*AUTO_WIDTH);
    share.titleLabel.font = [UIFont fontWithName:@"Arial" size:TEXTCONTENTFONT * TEXTWEIGHT];
    
    
    
    [share mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.alertView.mas_bottom).offset(-60.00*AUTO_WIDTH);
        make.right.equalTo(self.alertView.mas_right).offset(-80.00*AUTO_WIDTH);
        make.left.equalTo(self.alertView).offset(80.00*AUTO_WIDTH);
        //  make.size.mas_equalTo(CGSizeMake(20.00*WEIGHT,30.00*WEIGHT));
        make.height.mas_equalTo(30 * AUTO_HEIGHT);
        
        
    }];
    
    
    
    
    UIButton *chungajianButton = [UIButton buttonWithType:UIButtonTypeCustom];
    // [chungajianButton addTarget:self action:@selector(chuangjianActon:) forControlEvents:UIControlEventTouchUpInside];
    chungajianButton.layer.masksToBounds = YES;
    chungajianButton.layer.cornerRadius = 3;
    [chungajianButton setTitle:@"发布" forState:UIControlStateNormal];
    chungajianButton.backgroundColor  = GH;
    chungajianButton.titleLabel.font = [UIFont fontWithName:@"Arial" size:TEXTCONTENTFONT * TEXTWEIGHT];
    [chungajianButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    [self.alertView addSubview:chungajianButton];
    [chungajianButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.alertView.mas_bottom).offset(-20.00*AUTO_WIDTH);
        make.right.equalTo(self.alertView.mas_right).offset(-80.00*AUTO_WIDTH);
        make.left.equalTo(self.alertView).offset(80.00*AUTO_WIDTH);
        //  make.size.mas_equalTo(CGSizeMake(20.00*WEIGHT,30.00*WEIGHT));
        make.height.mas_equalTo(30 * AUTO_HEIGHT);
        
    }];
    
    
    
    
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(TapActionTwo:)];
    self.alertView.userInteractionEnabled = YES;
    [self.alertView addGestureRecognizer:tap];

    
}

- (void)TapActionTwo:(UITapGestureRecognizer *)tap{
    
    NSLog(@"dqwd");
    [self lew_dismissPopupView];
}




////返回按钮
//-(void) btnAction:(UIButton *) btn
//{
//    [self.navigationController popToRootViewControllerAnimated:YES];
//}


@end
